package com.zyf.springcloud.controller;

import com.zyf.springcloud.service.impl.PermissionServiceImpl;
import com.zyf.springcloud.service.impl.RolePermissionServiceImpl;
import com.zyf.springcloud.service.impl.RoleServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class APIController {
    @Autowired
    RolePermissionServiceImpl rolePermissionService;
    @Autowired
    RoleServiceImpl roleService;
    @Autowired
    PermissionServiceImpl permissionService;

    @PostMapping("/api/selectRoleByPermissionURL")
    public List<String> selectRoleEntitiesByPermissionURL(@RequestParam(value = "URL") String URL) {
        int PermissionId = permissionService.selectPermissionIdByPermissionURL(URL);
        List<Integer> list = rolePermissionService.selectRoleIdByPermissionId(PermissionId);
        return (List<String>) roleService.selectRoleNameByRoleId(list);
    }

}
